package com.falm.picturebackend.entity.convert;

import com.falm.picturebackend.entity.BO.FileMetadataBO;
import com.falm.picturebackend.entity.DO.FileMetadataDO;
import com.falm.picturebackend.entity.VO.FileMetadataVO;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Administrator
 */
public class FileMetadataConvert {

    public static FileMetadataBO do2BO(FileMetadataDO fileMetadataDO) {
        if (fileMetadataDO == null) {
            return null;
        }
        FileMetadataBO fileMetadataBO = new FileMetadataBO();
        fileMetadataBO.setId(fileMetadataDO.getId());
        fileMetadataBO.setFileUuid(fileMetadataDO.getFileUuid());
        fileMetadataBO.setMetaKey(fileMetadataDO.getMetaKey());
        fileMetadataBO.setMetaValue(fileMetadataDO.getMetaValue());
        fileMetadataBO.setCreateTime(fileMetadataDO.getCreateTime());
        fileMetadataBO.setUpdateTime(fileMetadataDO.getUpdateTime());
        return fileMetadataBO;
    }

    public static FileMetadataDO bo2DO(FileMetadataBO fileMetadataBO) {
        if (fileMetadataBO == null) {
            return null;
        }
        FileMetadataDO fileMetadataDO = new FileMetadataDO();
        fileMetadataDO.setId(fileMetadataBO.getId());
        fileMetadataDO.setFileUuid(fileMetadataBO.getFileUuid());
        fileMetadataDO.setMetaKey(fileMetadataBO.getMetaKey());
        fileMetadataDO.setMetaValue(fileMetadataBO.getMetaValue());
        fileMetadataDO.setCreateTime(fileMetadataBO.getCreateTime());
        fileMetadataDO.setUpdateTime(fileMetadataBO.getUpdateTime());
        return fileMetadataDO;
    }

    public static FileMetadataVO bo2VO(FileMetadataBO fileMetadataBO) {
        if (fileMetadataBO == null) {
            return null;
        }
        FileMetadataVO fileMetadataVO = new FileMetadataVO();
        fileMetadataVO.setId(fileMetadataBO.getId());
        fileMetadataVO.setFileUuid(fileMetadataBO.getFileUuid());
        fileMetadataVO.setMetaKey(fileMetadataBO.getMetaKey());
        fileMetadataVO.setMetaValue(fileMetadataBO.getMetaValue());
        fileMetadataVO.setCreateTime(fileMetadataBO.getCreateTime());
        fileMetadataVO.setUpdateTime(fileMetadataBO.getUpdateTime());
        return fileMetadataVO;
    }

    public static List<FileMetadataBO> do2BOList(List<FileMetadataDO> fileMetadataDOList) {
        return fileMetadataDOList.stream().map(FileMetadataConvert::do2BO).collect(Collectors.toList());
    }
}